package com.java.service;

import com.java.dao.TrackingMapper;
import com.java.pojo.EnterGood;
import com.java.pojo.Page;
import com.java.pojo.Tracking;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TrackingServiceImpl implements TrackingService {

    @Autowired
    private TrackingMapper trackingMapper;

    @Override
    public List<Tracking> getTrList() {
        return trackingMapper.getTrList();
    }

    @Override
    public Page<Tracking> getPageByTR(Integer a, String document) {
        int b=4;//显示条数
        Page<Tracking> page=new Page<>();
        page.setCurryPage(a);//设置当前页码
        page.setRows(b);//设置每页显示的条数
        Integer count = trackingMapper.getCountTracking(document);//总条数
        page.setTotalCount(count);//总条数
        int start=(a-1)*b;/*开始的索引*/
        List<Tracking> list = trackingMapper.getListTracking(start, b, document);
        page.setList(list);/*赋值list*/
        int totalPae=count % b==0 ? count / b : (count / b)+1;
        page.setTotalPae(totalPae);/*设置总页数*/
        if(page==null){
            page=null;
        }
        return page;
    }

    @Override
    public Integer getCountTR(String document) {
        return trackingMapper.getCountTracking(document);
    }
}
